
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GEOS API &#8212; Django 1.11.22.dev20190603194737 documentation</title>
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="GDAL API" href="gdal.html" />
    <link rel="prev" title="Measurement Objects" href="measure.html" />



 
<script type="text/javascript" src="../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 1.11.22.dev20190603194737 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="measure.html" title="Measurement Objects">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="gdal.html" title="GDAL API">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-contrib-gis-geos">
            
  <div class="section" id="s-module-django.contrib.gis.geos">
<span id="s-geos-api"></span><span id="module-django.contrib.gis.geos"></span><span id="geos-api"></span><h1>GEOS API<a class="headerlink" href="#module-django.contrib.gis.geos" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-background">
<span id="background"></span><h2>Background<a class="headerlink" href="#background" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-what-is-geos">
<span id="what-is-geos"></span><h3>What is GEOS?<a class="headerlink" href="#what-is-geos" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="https://trac.osgeo.org/geos/">GEOS</a> stands for <strong>Geometry Engine - Open Source</strong>,
and is a C++ library, ported from the  <a class="reference external" href="https://sourceforge.net/projects/jts-topo-suite/">Java Topology Suite</a>.  GEOS
implements the OpenGIS <a class="reference external" href="http://www.opengeospatial.org/standards/sfs">Simple Features for SQL</a> spatial predicate functions
and spatial operators. GEOS, now an OSGeo project, was initially developed and
maintained by <a class="reference external" href="http://www.refractions.net/">Refractions Research</a> of Victoria, Canada.</p>
</div>
<div class="section" id="s-features">
<span id="features"></span><h3>Features<a class="headerlink" href="#features" title="Permalink to this headline">¶</a></h3>
<p>GeoDjango implements a high-level Python wrapper for the GEOS library, its
features include:</p>
<ul class="simple">
<li>A BSD-licensed interface to the GEOS geometry routines, implemented purely
in Python using <code class="docutils literal notranslate"><span class="pre">ctypes</span></code>.</li>
<li>Loosely-coupled to GeoDjango.  For example, <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects
may be used outside of a Django project/application.  In other words,
no need to have <code class="docutils literal notranslate"><span class="pre">DJANGO_SETTINGS_MODULE</span></code> set or use a database, etc.</li>
<li>Mutability: <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects may be modified.</li>
<li>Cross-platform and tested; compatible with Windows, Linux, Solaris, and
macOS platforms.</li>
</ul>
</div>
</div>
<div class="section" id="s-tutorial">
<span id="s-geos-tutorial"></span><span id="tutorial"></span><span id="geos-tutorial"></span><h2>Tutorial<a class="headerlink" href="#tutorial" title="Permalink to this headline">¶</a></h2>
<p>This section contains a brief introduction and tutorial to using
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects.</p>
<div class="section" id="s-creating-a-geometry">
<span id="creating-a-geometry"></span><h3>Creating a Geometry<a class="headerlink" href="#creating-a-geometry" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects may be created in a few ways.  The first is
to simply instantiate the object on some spatial input – the following
are examples of creating the same geometry from WKT, HEX, WKB, and GeoJSON:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">GEOSGeometry</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">GEOSGeometry</span><span class="p">(</span><span class="s1">&#39;POINT(5 23)&#39;</span><span class="p">)</span> <span class="c1"># WKT</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">GEOSGeometry</span><span class="p">(</span><span class="s1">&#39;010100000000000000000014400000000000003740&#39;</span><span class="p">)</span> <span class="c1"># HEX</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">GEOSGeometry</span><span class="p">(</span><span class="n">buffer</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14</span><span class="s1">@</span><span class="se">\x00\x00\x00\x00\x00\x00</span><span class="s1">7@&#39;</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">GEOSGeometry</span><span class="p">(</span><span class="s1">&#39;{ &quot;type&quot;: &quot;Point&quot;, &quot;coordinates&quot;: [ 5.000000, 23.000000 ] }&#39;</span><span class="p">)</span> <span class="c1"># GeoJSON</span>
</pre></div>
</div>
<p>Another option is to use the constructor for the specific geometry type
that you wish to create.  For example, a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> object may be
created by passing in the X and Y coordinates into its constructor:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">23</span><span class="p">)</span>
</pre></div>
</div>
<p>All these constructors take the keyword argument <code class="docutils literal notranslate"><span class="pre">srid</span></code>. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">GEOSGeometry</span><span class="p">,</span> <span class="n">LineString</span><span class="p">,</span> <span class="n">Point</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">GEOSGeometry</span><span class="p">(</span><span class="s1">&#39;POINT (0 0)&#39;</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">))</span>
<span class="go">SRID=4326;POINT (0 0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">))</span>
<span class="go">SRID=4326;LINESTRING (0 0, 1 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="mi">32140</span><span class="p">))</span>
<span class="go">SRID=32140;POINT (0 0)</span>
</pre></div>
</div>
<p>Finally, there is the <a class="reference internal" href="#django.contrib.gis.geos.fromfile" title="django.contrib.gis.geos.fromfile"><code class="xref py py-func docutils literal notranslate"><span class="pre">fromfile()</span></code></a> factory method which returns a
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> object from a file:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">fromfile</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">fromfile</span><span class="p">(</span><span class="s1">&#39;/path/to/pnt.wkt&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">fromfile</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s1">&#39;/path/to/pnt.wkt&#39;</span><span class="p">))</span>
</pre></div>
</div>
<div class="admonition-my-logs-are-filled-with-geos-related-errors admonition" id="geos-exceptions-in-logfile">
<p class="first admonition-title">My logs are filled with GEOS-related errors</p>
<p class="last">You find many <code class="docutils literal notranslate"><span class="pre">TypeError</span></code> or <code class="docutils literal notranslate"><span class="pre">AttributeError</span></code> exceptions filling your
Web server’s log files. This generally means that you are creating GEOS
objects at the top level of some of your Python modules. Then, due to a race
condition in the garbage collector, your module is garbage collected before
the GEOS object. To prevent this, create <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects
inside the local scope of your functions/methods.</p>
</div>
</div>
<div class="section" id="s-geometries-are-pythonic">
<span id="geometries-are-pythonic"></span><h3>Geometries are Pythonic<a class="headerlink" href="#geometries-are-pythonic" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects are ‘Pythonic’, in other words components may
be accessed, modified, and iterated over using standard Python conventions.
For example, you can iterate over the coordinates in a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">23</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">coord</span> <span class="k">for</span> <span class="n">coord</span> <span class="ow">in</span> <span class="n">pnt</span><span class="p">]</span>
<span class="go">[5.0, 23.0]</span>
</pre></div>
</div>
<p>With any geometry object, the <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.coords" title="django.contrib.gis.geos.GEOSGeometry.coords"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.coords</span></code></a> property
may be used to get the geometry coordinates as a Python tuple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span><span class="o">.</span><span class="n">coords</span>
<span class="go">(5.0, 23.0)</span>
</pre></div>
</div>
<p>You can get/set geometry components using standard Python indexing
techniques.  However, what is returned depends on the geometry type
of the object.  For example, indexing on a <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a>
returns a coordinate tuple:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">LineString</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">50</span><span class="p">),</span> <span class="p">(</span><span class="mi">50</span><span class="p">,</span> <span class="mi">50</span><span class="p">),</span> <span class="p">(</span><span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">(0.0, 0.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span>
<span class="go">(50.0, 0.0)</span>
</pre></div>
</div>
<p>Whereas indexing on a <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> will return the ring
(a <a class="reference internal" href="#django.contrib.gis.geos.LinearRing" title="django.contrib.gis.geos.LinearRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">LinearRing</span></code></a> object) corresponding to the index:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Polygon</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span> <span class="p">((</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">50.0</span><span class="p">),</span> <span class="p">(</span><span class="mf">50.0</span><span class="p">,</span> <span class="mf">50.0</span><span class="p">),</span> <span class="p">(</span><span class="mf">50.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">))</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">&lt;LinearRing object at 0x1044395b0&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span> <span class="c1"># second-to-last coordinate of external ring</span>
<span class="go">(50.0, 0.0)</span>
</pre></div>
</div>
<p>In addition, coordinates/components of the geometry may added or modified,
just like a Python list:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
<span class="go">(0.0, 0.0)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">line</span><span class="o">.</span><span class="n">coords</span>
<span class="go">((1.0, 1.0), (0.0, 50.0), (50.0, 50.0), (50.0, 0.0), (1.0, 1.0))</span>
</pre></div>
</div>
<p>Geometries support set-like operators:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">LineString</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls1</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls2</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ls1</span> <span class="o">|</span> <span class="n">ls2</span><span class="p">)</span>  <span class="c1"># equivalent to `ls1.union(ls2)`</span>
<span class="go">MULTILINESTRING ((0 0, 1 1), (1 1, 2 2), (2 2, 3 3))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ls1</span> <span class="o">&amp;</span> <span class="n">ls2</span><span class="p">)</span>  <span class="c1"># equivalent to `ls1.intersection(ls2)`</span>
<span class="go">LINESTRING (1 1, 2 2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ls1</span> <span class="o">-</span> <span class="n">ls2</span><span class="p">)</span>  <span class="c1"># equivalent to `ls1.difference(ls2)`</span>
<span class="go">LINESTRING(0 0, 1 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">ls1</span> <span class="o">^</span> <span class="n">ls2</span><span class="p">)</span>  <span class="c1"># equivalent to `ls1.sym_difference(ls2)`</span>
<span class="go">MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))</span>
</pre></div>
</div>
<div class="admonition-equality-operator-doesn-t-check-spatial-equality admonition">
<p class="first admonition-title">Equality operator doesn’t check spatial equality</p>
<p>The <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> equality operator uses
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.equals_exact" title="django.contrib.gis.geos.GEOSGeometry.equals_exact"><code class="xref py py-meth docutils literal notranslate"><span class="pre">equals_exact()</span></code></a>, not <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.equals" title="django.contrib.gis.geos.GEOSGeometry.equals"><code class="xref py py-meth docutils literal notranslate"><span class="pre">equals()</span></code></a>, i.e.
it requires the compared geometries to have the same coordinates in the
same positions with the same SRIDs:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">LineString</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls1</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls2</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls3</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls1</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">ls2</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls1</span> <span class="o">==</span> <span class="n">ls2</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls3</span> <span class="o">==</span> <span class="n">ls2</span>  <span class="c1"># different SRIDs</span>
<span class="go">False</span>
</pre></div>
</div>
<div class="last versionchanged">
<span class="title">Changed in Django 1.11:</span> <p>Older versions didn’t check the <code class="docutils literal notranslate"><span class="pre">srid</span></code> when comparing
<code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code> objects using the equality operator.</p>
</div>
</div>
</div>
</div>
<div class="section" id="s-geometry-objects">
<span id="geometry-objects"></span><h2>Geometry Objects<a class="headerlink" href="#geometry-objects" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-geosgeometry">
<span id="geosgeometry"></span><h3><code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code><a class="headerlink" href="#geosgeometry" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.GEOSGeometry">
<em class="property">class </em><code class="descname">GEOSGeometry</code>(<em>geo_input</em>, <em>srid=None</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>geo_input</strong> – Geometry input value (string or buffer)</li>
<li><strong>srid</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – spatial reference identifier</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<p>This is the base class for all GEOS geometry objects.  It initializes on the
given <code class="docutils literal notranslate"><span class="pre">geo_input</span></code> argument, and then assumes the proper geometry subclass
(e.g., <code class="docutils literal notranslate"><span class="pre">GEOSGeometry('POINT(1</span> <span class="pre">1)')</span></code> will create a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> object).</p>
<p>The following input formats, along with their corresponding Python types,
are accepted:</p>
<table class="docutils">
<colgroup>
<col width="51%" />
<col width="49%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Format</th>
<th class="head">Input Type</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>WKT / EWKT</td>
<td><code class="docutils literal notranslate"><span class="pre">str</span></code> or <code class="docutils literal notranslate"><span class="pre">unicode</span></code></td>
</tr>
<tr class="row-odd"><td>HEX / HEXEWKB</td>
<td><code class="docutils literal notranslate"><span class="pre">str</span></code> or <code class="docutils literal notranslate"><span class="pre">unicode</span></code></td>
</tr>
<tr class="row-even"><td>WKB / EWKB</td>
<td><code class="docutils literal notranslate"><span class="pre">buffer</span></code></td>
</tr>
<tr class="row-odd"><td>GeoJSON</td>
<td><code class="docutils literal notranslate"><span class="pre">str</span></code> or <code class="docutils literal notranslate"><span class="pre">unicode</span></code></td>
</tr>
</tbody>
</table>
<dl class="classmethod">
<dt id="django.contrib.gis.geos.GEOSGeometry.from_gml">
<em class="property">classmethod </em><code class="descclassname">GEOSGeometry.</code><code class="descname">from_gml</code>(<em>gml_string</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.from_gml" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.11.</span> </div>
<p>Constructs a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> from the given GML string.</p>
</dd></dl>

<div class="section" id="s-properties">
<span id="properties"></span><h4>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h4>
<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.coords">
<code class="descclassname">GEOSGeometry.</code><code class="descname">coords</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.coords" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the coordinates of the geometry as a tuple.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.dims">
<code class="descclassname">GEOSGeometry.</code><code class="descname">dims</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.dims" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the dimension of the geometry:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">0</span></code> for <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a>s and <a class="reference internal" href="#django.contrib.gis.geos.MultiPoint" title="django.contrib.gis.geos.MultiPoint"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiPoint</span></code></a>s</li>
<li><code class="docutils literal notranslate"><span class="pre">1</span></code> for <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a>s and <a class="reference internal" href="#django.contrib.gis.geos.MultiLineString" title="django.contrib.gis.geos.MultiLineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiLineString</span></code></a>s</li>
<li><code class="docutils literal notranslate"><span class="pre">2</span></code> for <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a>s and <a class="reference internal" href="#django.contrib.gis.geos.MultiPolygon" title="django.contrib.gis.geos.MultiPolygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiPolygon</span></code></a>s</li>
<li><code class="docutils literal notranslate"><span class="pre">-1</span></code> for empty <a class="reference internal" href="#django.contrib.gis.geos.GeometryCollection" title="django.contrib.gis.geos.GeometryCollection"><code class="xref py py-class docutils literal notranslate"><span class="pre">GeometryCollection</span></code></a>s</li>
<li>the maximum dimension of its elements for non-empty
<a class="reference internal" href="#django.contrib.gis.geos.GeometryCollection" title="django.contrib.gis.geos.GeometryCollection"><code class="xref py py-class docutils literal notranslate"><span class="pre">GeometryCollection</span></code></a>s</li>
</ul>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.empty">
<code class="descclassname">GEOSGeometry.</code><code class="descname">empty</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.empty" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns whether or not the set of points in the geometry is empty.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.geom_type">
<code class="descclassname">GEOSGeometry.</code><code class="descname">geom_type</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.geom_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a string corresponding to the type of geometry.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">GEOSGeometry</span><span class="p">(</span><span class="s1">&#39;POINT(5 23)&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span><span class="o">.</span><span class="n">geom_type</span>
<span class="go">&#39;Point&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.geom_typeid">
<code class="descclassname">GEOSGeometry.</code><code class="descname">geom_typeid</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.geom_typeid" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the GEOS geometry type identification number.  The following table
shows the value for each geometry type:</p>
<table class="docutils">
<colgroup>
<col width="77%" />
<col width="23%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Geometry</th>
<th class="head">ID</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a></td>
<td>0</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a></td>
<td>1</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#django.contrib.gis.geos.LinearRing" title="django.contrib.gis.geos.LinearRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">LinearRing</span></code></a></td>
<td>2</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a></td>
<td>3</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#django.contrib.gis.geos.MultiPoint" title="django.contrib.gis.geos.MultiPoint"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiPoint</span></code></a></td>
<td>4</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#django.contrib.gis.geos.MultiLineString" title="django.contrib.gis.geos.MultiLineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiLineString</span></code></a></td>
<td>5</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#django.contrib.gis.geos.MultiPolygon" title="django.contrib.gis.geos.MultiPolygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiPolygon</span></code></a></td>
<td>6</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#django.contrib.gis.geos.GeometryCollection" title="django.contrib.gis.geos.GeometryCollection"><code class="xref py py-class docutils literal notranslate"><span class="pre">GeometryCollection</span></code></a></td>
<td>7</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.num_coords">
<code class="descclassname">GEOSGeometry.</code><code class="descname">num_coords</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.num_coords" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of coordinates in the geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.num_geom">
<code class="descclassname">GEOSGeometry.</code><code class="descname">num_geom</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.num_geom" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of geometries in this geometry.  In other words, will
return 1 on anything but geometry collections.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.hasz">
<code class="descclassname">GEOSGeometry.</code><code class="descname">hasz</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.hasz" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a boolean indicating whether the geometry is three-dimensional.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.ring">
<code class="descclassname">GEOSGeometry.</code><code class="descname">ring</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.ring" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a boolean indicating whether the geometry is a <code class="docutils literal notranslate"><span class="pre">LinearRing</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.simple">
<code class="descclassname">GEOSGeometry.</code><code class="descname">simple</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.simple" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a boolean indicating whether the geometry is ‘simple’. A geometry
is simple if and only if it does not intersect itself (except at boundary
points).  For example, a <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> object is not simple if it
intersects itself. Thus, <a class="reference internal" href="#django.contrib.gis.geos.LinearRing" title="django.contrib.gis.geos.LinearRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">LinearRing</span></code></a> and <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> objects
are always simple because they do cannot intersect themselves, by
definition.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.valid">
<code class="descclassname">GEOSGeometry.</code><code class="descname">valid</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.valid" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a boolean indicating whether the geometry is valid.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.valid_reason">
<code class="descclassname">GEOSGeometry.</code><code class="descname">valid_reason</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.valid_reason" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a string describing the reason why a geometry is invalid.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.srid">
<code class="descclassname">GEOSGeometry.</code><code class="descname">srid</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.srid" title="Permalink to this definition">¶</a></dt>
<dd><p>Property that may be used to retrieve or set the SRID associated with the
geometry.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">23</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">pnt</span><span class="o">.</span><span class="n">srid</span><span class="p">)</span>
<span class="go">None</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span><span class="o">.</span><span class="n">srid</span> <span class="o">=</span> <span class="mi">4326</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span><span class="o">.</span><span class="n">srid</span>
<span class="go">4326</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-output-properties">
<span id="output-properties"></span><h4>Output Properties<a class="headerlink" href="#output-properties" title="Permalink to this headline">¶</a></h4>
<p>The properties in this section export the <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> object into
a different.  This output may be in the form of a string, buffer, or even
another object.</p>
<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.ewkt">
<code class="descclassname">GEOSGeometry.</code><code class="descname">ewkt</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.ewkt" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the “extended” Well-Known Text of the geometry.  This representation
is specific to PostGIS and is a superset of the OGC WKT standard. <a class="footnote-reference" href="#fnogc" id="id5">[1]</a>
Essentially the SRID is prepended to the WKT representation, for example
<code class="docutils literal notranslate"><span class="pre">SRID=4326;POINT(5</span> <span class="pre">23)</span></code>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The output from this property does not include the 3dm, 3dz, and 4d
information that PostGIS supports in its EWKT representations.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.hex">
<code class="descclassname">GEOSGeometry.</code><code class="descname">hex</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.hex" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the WKB of this Geometry in hexadecimal form.  Please note
that the SRID value is not included in this representation
because it is not a part of the OGC specification (use the
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.hexewkb" title="django.contrib.gis.geos.GEOSGeometry.hexewkb"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.hexewkb</span></code></a> property instead).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.hexewkb">
<code class="descclassname">GEOSGeometry.</code><code class="descname">hexewkb</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.hexewkb" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the EWKB of this Geometry in hexadecimal form.  This is an
extension of the WKB specification that includes the SRID value
that are a part of this geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.json">
<code class="descclassname">GEOSGeometry.</code><code class="descname">json</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.json" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the GeoJSON representation of the geometry. Note that the result is
not a complete GeoJSON structure but only the <code class="docutils literal notranslate"><span class="pre">geometry</span></code> key content of a
GeoJSON structure. See also <a class="reference internal" href="serializers.html"><span class="doc">GeoJSON Serializer</span></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.geojson">
<code class="descclassname">GEOSGeometry.</code><code class="descname">geojson</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.geojson" title="Permalink to this definition">¶</a></dt>
<dd><p>Alias for <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.json" title="django.contrib.gis.geos.GEOSGeometry.json"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.json</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.kml">
<code class="descclassname">GEOSGeometry.</code><code class="descname">kml</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.kml" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference external" href="https://developers.google.com/kml/documentation/">KML</a> (Keyhole Markup Language) representation of the
geometry.  This should only be used for geometries with an SRID of
4326 (WGS84), but this restriction is not enforced.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.ogr">
<code class="descclassname">GEOSGeometry.</code><code class="descname">ogr</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.ogr" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an <a class="reference internal" href="gdal.html#django.contrib.gis.gdal.OGRGeometry" title="django.contrib.gis.gdal.OGRGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">OGRGeometry</span></code></a> object
corresponding to the GEOS geometry.</p>
</dd></dl>

<span class="target" id="wkb"></span><dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.wkb">
<code class="descclassname">GEOSGeometry.</code><code class="descname">wkb</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.wkb" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer.  SRID value is not included, use the
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.ewkb" title="django.contrib.gis.geos.GEOSGeometry.ewkb"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.ewkb</span></code></a> property instead.</p>
</dd></dl>

<span class="target" id="ewkb"></span><dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.ewkb">
<code class="descclassname">GEOSGeometry.</code><code class="descname">ewkb</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.ewkb" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
value that are a part of this geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.wkt">
<code class="descclassname">GEOSGeometry.</code><code class="descname">wkt</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.wkt" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the Well-Known Text of the geometry (an OGC standard).</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>Non-significant zeros are stripped from the output.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-spatial-predicate-methods">
<span id="spatial-predicate-methods"></span><h4>Spatial Predicate Methods<a class="headerlink" href="#spatial-predicate-methods" title="Permalink to this headline">¶</a></h4>
<p>All of the following spatial predicate methods take another
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> instance (<code class="docutils literal notranslate"><span class="pre">other</span></code>) as a parameter, and
return a boolean.</p>
<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.contains">
<code class="descclassname">GEOSGeometry.</code><code class="descname">contains</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.within" title="django.contrib.gis.geos.GEOSGeometry.within"><code class="xref py py-meth docutils literal notranslate"><span class="pre">other.within(this)</span></code></a> returns
<code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.covers">
<code class="descclassname">GEOSGeometry.</code><code class="descname">covers</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.covers" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if this geometry covers the specified geometry.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">covers</span></code> predicate has the following equivalent definitions:</p>
<ul class="simple">
<li>Every point of the other geometry is a point of this geometry.</li>
<li>The DE-9IM Intersection Matrix for the two geometries is
<code class="docutils literal notranslate"><span class="pre">T*****FF*</span></code>, <code class="docutils literal notranslate"><span class="pre">*T****FF*</span></code>, <code class="docutils literal notranslate"><span class="pre">***T**FF*</span></code>, or <code class="docutils literal notranslate"><span class="pre">****T*FF*</span></code>.</li>
</ul>
<p>If either geometry is empty, returns <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
<p>This predicate is similar to <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.contains" title="django.contrib.gis.geos.GEOSGeometry.contains"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GEOSGeometry.contains()</span></code></a>, but is more
inclusive (i.e. returns <code class="docutils literal notranslate"><span class="pre">True</span></code> for more cases). In particular, unlike
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.contains" title="django.contrib.gis.geos.GEOSGeometry.contains"><code class="xref py py-meth docutils literal notranslate"><span class="pre">contains()</span></code></a> it does not distinguish between points in the
boundary and in the interior of geometries. For most situations,
<code class="docutils literal notranslate"><span class="pre">covers()</span></code> should be preferred to <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.contains" title="django.contrib.gis.geos.GEOSGeometry.contains"><code class="xref py py-meth docutils literal notranslate"><span class="pre">contains()</span></code></a>. As an
added benefit, <code class="docutils literal notranslate"><span class="pre">covers()</span></code> is more amenable to optimization and hence
should outperform <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.contains" title="django.contrib.gis.geos.GEOSGeometry.contains"><code class="xref py py-meth docutils literal notranslate"><span class="pre">contains()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.crosses">
<code class="descclassname">GEOSGeometry.</code><code class="descname">crosses</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.crosses" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the DE-9IM intersection matrix for the two Geometries
is <code class="docutils literal notranslate"><span class="pre">T*T******</span></code> (for a point and a curve,a point and an area or a line
and an area) <code class="docutils literal notranslate"><span class="pre">0********</span></code> (for two curves).</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.disjoint">
<code class="descclassname">GEOSGeometry.</code><code class="descname">disjoint</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.disjoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the DE-9IM intersection matrix for the two geometries
is <code class="docutils literal notranslate"><span class="pre">FF*FF****</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.equals">
<code class="descclassname">GEOSGeometry.</code><code class="descname">equals</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.equals" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the DE-9IM intersection matrix for the two geometries
is <code class="docutils literal notranslate"><span class="pre">T*F**FFF*</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.equals_exact">
<code class="descclassname">GEOSGeometry.</code><code class="descname">equals_exact</code>(<em>other</em>, <em>tolerance=0</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.equals_exact" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if the two geometries are exactly equal, up to a
specified tolerance.  The <code class="docutils literal notranslate"><span class="pre">tolerance</span></code> value should be a floating
point number representing the error tolerance in the comparison, e.g.,
<code class="docutils literal notranslate"><span class="pre">poly1.equals_exact(poly2,</span> <span class="pre">0.001)</span></code> will compare equality to within
one thousandth of a unit.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.intersects">
<code class="descclassname">GEOSGeometry.</code><code class="descname">intersects</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.intersects" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.disjoint" title="django.contrib.gis.geos.GEOSGeometry.disjoint"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GEOSGeometry.disjoint()</span></code></a> is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.overlaps">
<code class="descclassname">GEOSGeometry.</code><code class="descname">overlaps</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.overlaps" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if the DE-9IM intersection matrix for the two geometries
is <code class="docutils literal notranslate"><span class="pre">T*T***T**</span></code> (for two points or two surfaces) <code class="docutils literal notranslate"><span class="pre">1*T***T**</span></code>
(for two curves).</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.relate_pattern">
<code class="descclassname">GEOSGeometry.</code><code class="descname">relate_pattern</code>(<em>other</em>, <em>pattern</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.relate_pattern" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the elements in the DE-9IM intersection matrix
for this geometry and the other matches the given <code class="docutils literal notranslate"><span class="pre">pattern</span></code> –
a string of nine characters from the alphabet: {<code class="docutils literal notranslate"><span class="pre">T</span></code>, <code class="docutils literal notranslate"><span class="pre">F</span></code>, <code class="docutils literal notranslate"><span class="pre">*</span></code>, <code class="docutils literal notranslate"><span class="pre">0</span></code>}.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.touches">
<code class="descclassname">GEOSGeometry.</code><code class="descname">touches</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.touches" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the DE-9IM intersection matrix for the two geometries
is <code class="docutils literal notranslate"><span class="pre">FT*******</span></code>, <code class="docutils literal notranslate"><span class="pre">F**T*****</span></code> or <code class="docutils literal notranslate"><span class="pre">F***T****</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.within">
<code class="descclassname">GEOSGeometry.</code><code class="descname">within</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.within" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the DE-9IM intersection matrix for the two geometries
is <code class="docutils literal notranslate"><span class="pre">T*F**F***</span></code>.</p>
</dd></dl>

</div>
<div class="section" id="s-topological-methods">
<span id="topological-methods"></span><h4>Topological Methods<a class="headerlink" href="#topological-methods" title="Permalink to this headline">¶</a></h4>
<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.buffer">
<code class="descclassname">GEOSGeometry.</code><code class="descname">buffer</code>(<em>width</em>, <em>quadsegs=8</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.buffer" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> that represents all points whose distance
from this geometry is less than or equal to the given <code class="docutils literal notranslate"><span class="pre">width</span></code>. The
optional <code class="docutils literal notranslate"><span class="pre">quadsegs</span></code> keyword sets the number of segments used to
approximate a quarter circle (defaults is 8).</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.difference">
<code class="descclassname">GEOSGeometry.</code><code class="descname">difference</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.difference" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> representing the points making up this
geometry that do not make up other.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.interpolate">
<code class="descclassname">GEOSGeometry.</code><code class="descname">interpolate</code>(<em>distance</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.interpolate" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.interpolate_normalized">
<code class="descclassname">GEOSGeometry.</code><code class="descname">interpolate_normalized</code>(<em>distance</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.interpolate_normalized" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a distance (float), returns the point (or closest point) within the
geometry (<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> or <a class="reference internal" href="#django.contrib.gis.geos.MultiLineString" title="django.contrib.gis.geos.MultiLineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiLineString</span></code></a>) at that distance.
The normalized version takes the distance as a float between 0 (origin) and
1 (endpoint).</p>
<p>Reverse of <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.project" title="django.contrib.gis.geos.GEOSGeometry.project"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GEOSGeometry.project()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.intersection">
<code class="descclassname">GEOSGeometry.</code><code class="descname">intersection</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.intersection" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> representing the points shared by this
geometry and other.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.project">
<code class="descclassname">GEOSGeometry.</code><code class="descname">project</code>(<em>point</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.project" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.project_normalized">
<code class="descclassname">GEOSGeometry.</code><code class="descname">project_normalized</code>(<em>point</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.project_normalized" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the distance (float) from the origin of the geometry
(<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> or <a class="reference internal" href="#django.contrib.gis.geos.MultiLineString" title="django.contrib.gis.geos.MultiLineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiLineString</span></code></a>) to the point projected on
the geometry (that is to a point of the line the closest to the given
point). The normalized version returns the distance as a float between 0
(origin) and 1 (endpoint).</p>
<p>Reverse of <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.interpolate" title="django.contrib.gis.geos.GEOSGeometry.interpolate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GEOSGeometry.interpolate()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.relate">
<code class="descclassname">GEOSGeometry.</code><code class="descname">relate</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.relate" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the DE-9IM intersection matrix (a string) representing the
topological relationship between this geometry and the other.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.simplify">
<code class="descclassname">GEOSGeometry.</code><code class="descname">simplify</code>(<em>tolerance=0.0</em>, <em>preserve_topology=False</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.simplify" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a new <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a>, simplified to the specified tolerance
using the Douglas-Peucker algorithm. A higher tolerance value implies
fewer points in the output. If no tolerance is provided, it defaults to 0.</p>
<p>By default, this function does not preserve topology. For example,
<a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> objects can be split, be collapsed into lines, or
disappear. <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> holes can be created or disappear, and lines may
cross. By specifying <code class="docutils literal notranslate"><span class="pre">preserve_topology=True</span></code>, the result will have the
same dimension and number of components as the input; this is significantly
slower, however.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.sym_difference">
<code class="descclassname">GEOSGeometry.</code><code class="descname">sym_difference</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.sym_difference" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> combining the points in this geometry
not in other, and the points in other not in this geometry.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.union">
<code class="descclassname">GEOSGeometry.</code><code class="descname">union</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.union" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> representing all the points in this
geometry and the other.</p>
</dd></dl>

</div>
<div class="section" id="s-topological-properties">
<span id="topological-properties"></span><h4>Topological Properties<a class="headerlink" href="#topological-properties" title="Permalink to this headline">¶</a></h4>
<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.boundary">
<code class="descclassname">GEOSGeometry.</code><code class="descname">boundary</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.boundary" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the boundary as a newly allocated Geometry object.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.centroid">
<code class="descclassname">GEOSGeometry.</code><code class="descname">centroid</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.centroid" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> object representing the geometric center of
the geometry.  The point is not guaranteed to be on the interior
of the geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.convex_hull">
<code class="descclassname">GEOSGeometry.</code><code class="descname">convex_hull</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.convex_hull" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the smallest <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> that contains all the points in
the geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.envelope">
<code class="descclassname">GEOSGeometry.</code><code class="descname">envelope</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.envelope" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> that represents the bounding envelope of
this geometry. Note that it can also return a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> if the input
geometry is a point.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.point_on_surface">
<code class="descclassname">GEOSGeometry.</code><code class="descname">point_on_surface</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.point_on_surface" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes and returns a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> guaranteed to be on the interior
of this geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.unary_union">
<code class="descclassname">GEOSGeometry.</code><code class="descname">unary_union</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.unary_union" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>Computes the union of all the elements of this geometry.</p>
<p>The result obeys the following contract:</p>
<ul class="simple">
<li>Unioning a set of <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a>s has the effect of fully noding and
dissolving the linework.</li>
<li>Unioning a set of <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a>s will always return a <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a>
or <a class="reference internal" href="#django.contrib.gis.geos.MultiPolygon" title="django.contrib.gis.geos.MultiPolygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiPolygon</span></code></a> geometry (unlike <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.union" title="django.contrib.gis.geos.GEOSGeometry.union"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GEOSGeometry.union()</span></code></a>,
which may return geometries of lower dimension if a topology collapse
occurs).</li>
</ul>
</dd></dl>

</div>
<div class="section" id="s-other-properties-methods">
<span id="other-properties-methods"></span><h4>Other Properties &amp; Methods<a class="headerlink" href="#other-properties-methods" title="Permalink to this headline">¶</a></h4>
<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.area">
<code class="descclassname">GEOSGeometry.</code><code class="descname">area</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.area" title="Permalink to this definition">¶</a></dt>
<dd><p>This property returns the area of the Geometry.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.extent">
<code class="descclassname">GEOSGeometry.</code><code class="descname">extent</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.extent" title="Permalink to this definition">¶</a></dt>
<dd><p>This property returns the extent of this geometry as a 4-tuple,
consisting of <code class="docutils literal notranslate"><span class="pre">(xmin,</span> <span class="pre">ymin,</span> <span class="pre">xmax,</span> <span class="pre">ymax)</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.clone">
<code class="descclassname">GEOSGeometry.</code><code class="descname">clone</code>()<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>This method returns a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> that is a clone of the original.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.distance">
<code class="descclassname">GEOSGeometry.</code><code class="descname">distance</code>(<em>geom</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.distance" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the distance between the closest points on this geometry and the
given <code class="docutils literal notranslate"><span class="pre">geom</span></code> (another <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> object).</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">GEOS distance calculations are  linear – in other words, GEOS does not
perform a spherical calculation even if the SRID specifies a geographic
coordinate system.</p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.length">
<code class="descclassname">GEOSGeometry.</code><code class="descname">length</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.length" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the length of this geometry (e.g., 0 for a <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a>,
the length of a <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a>, or the circumference of
a <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a>).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.prepared">
<code class="descclassname">GEOSGeometry.</code><code class="descname">prepared</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.prepared" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a GEOS <code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code> for the contents of this geometry.
<code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code> objects are optimized for the contains, intersects,
covers, crosses, disjoint, overlaps, touches and within operations. Refer to
the <a class="reference internal" href="#prepared-geometries"><span class="std std-ref">Prepared Geometries</span></a> documentation for more information.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.GEOSGeometry.srs">
<code class="descclassname">GEOSGeometry.</code><code class="descname">srs</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.srs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="gdal.html#django.contrib.gis.gdal.SpatialReference" title="django.contrib.gis.gdal.SpatialReference"><code class="xref py py-class docutils literal notranslate"><span class="pre">SpatialReference</span></code></a> object
corresponding to the SRID of the geometry or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.transform">
<code class="descclassname">GEOSGeometry.</code><code class="descname">transform</code>(<em>ct</em>, <em>clone=False</em>)<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Transforms the geometry according to the given coordinate transformation
parameter (<code class="docutils literal notranslate"><span class="pre">ct</span></code>), which may be an integer SRID, spatial reference WKT
string, a PROJ.4 string, a
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.SpatialReference" title="django.contrib.gis.gdal.SpatialReference"><code class="xref py py-class docutils literal notranslate"><span class="pre">SpatialReference</span></code></a> object, or a
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.CoordTransform" title="django.contrib.gis.gdal.CoordTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">CoordTransform</span></code></a> object. By default, the
geometry is transformed in-place and nothing is returned. However if the
<code class="docutils literal notranslate"><span class="pre">clone</span></code> keyword is set, then the geometry is not modified and a
transformed clone of the geometry is returned instead.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Raises <a class="reference internal" href="#django.contrib.gis.geos.GEOSException" title="django.contrib.gis.geos.GEOSException"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSException</span></code></a> if GDAL is not
available or if the geometry’s SRID is <code class="docutils literal notranslate"><span class="pre">None</span></code> or less than 0. It
doesn’t impose any constraints on the geometry’s SRID if called with a
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.CoordTransform" title="django.contrib.gis.gdal.CoordTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">CoordTransform</span></code></a> object.</p>
<div class="last versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, it required the geometry’s SRID to be a
positive integer even if it was called with a
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.CoordTransform" title="django.contrib.gis.gdal.CoordTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">CoordTransform</span></code></a> object.</p>
</div>
</div>
</dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.GEOSGeometry.normalize">
<code class="descclassname">GEOSGeometry.</code><code class="descname">normalize</code>()<a class="headerlink" href="#django.contrib.gis.geos.GEOSGeometry.normalize" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts this geometry to canonical form:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">MultiPoint</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
<span class="go">MULTIPOINT (0 0, 2 2, 1 1)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">normalize</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">g</span><span class="p">)</span>
<span class="go">MULTIPOINT (2 2, 1 1, 0 0)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="s-point">
<span id="point"></span><h3><code class="docutils literal notranslate"><span class="pre">Point</span></code><a class="headerlink" href="#point" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.Point">
<em class="property">class </em><code class="descname">Point</code>(<em>x=None</em>, <em>y=None</em>, <em>z=None</em>, <em>srid=None</em>)<a class="headerlink" href="#django.contrib.gis.geos.Point" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">Point</span></code> objects are instantiated using arguments that represent the
component coordinates of the point or with a single sequence coordinates.
For example, the following are equivalent:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">23</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">([</span><span class="mi">5</span><span class="p">,</span> <span class="mi">23</span><span class="p">])</span>
</pre></div>
</div>
<p>Empty <code class="docutils literal notranslate"><span class="pre">Point</span></code> objects may be instantiated by passing no arguments or an
empty sequence. The following are equivalent:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">([])</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">Point</span></code> couldn’t be instantiated.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-linestring">
<span id="linestring"></span><h3><code class="docutils literal notranslate"><span class="pre">LineString</span></code><a class="headerlink" href="#linestring" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.LineString">
<em class="property">class </em><code class="descname">LineString</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.LineString" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">LineString</span></code> objects are instantiated using arguments that are either a
sequence of coordinates or <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> objects. For example, the
following are equivalent:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
</pre></div>
</div>
<p>In addition, <code class="docutils literal notranslate"><span class="pre">LineString</span></code> objects may also be created by passing in a
single sequence of coordinate or <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">(</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">(</span> <span class="p">[</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)]</span> <span class="p">)</span>
</pre></div>
</div>
<p>Empty <code class="docutils literal notranslate"><span class="pre">LineString</span></code> objects may be instantiated by passing no arguments
or an empty sequence. The following are equivalent:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">([])</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">LineString</span></code> couldn’t be instantiated.</p>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.LineString.closed">
<code class="descname">closed</code><a class="headerlink" href="#django.contrib.gis.geos.LineString.closed" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>Returns whether or not this <code class="docutils literal notranslate"><span class="pre">LineString</span></code> is closed.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-linearring">
<span id="linearring"></span><h3><code class="docutils literal notranslate"><span class="pre">LinearRing</span></code><a class="headerlink" href="#linearring" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.LinearRing">
<em class="property">class </em><code class="descname">LinearRing</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.LinearRing" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">LinearRing</span></code> objects are constructed in the exact same way as
<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> objects, however the coordinates must be <em>closed</em>, in
other words, the first coordinates must be the same as the last
coordinates. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ls</span> <span class="o">=</span> <span class="n">LinearRing</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
</pre></div>
</div>
<p>Notice that <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code> is the first and last coordinate – if they were not
equal, an error would be raised.</p>
</dd></dl>

</div>
<div class="section" id="s-polygon">
<span id="polygon"></span><h3><code class="docutils literal notranslate"><span class="pre">Polygon</span></code><a class="headerlink" href="#polygon" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.Polygon">
<em class="property">class </em><code class="descname">Polygon</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.Polygon" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">Polygon</span></code> objects may be instantiated by passing in parameters that
represent the rings of the polygon.  The parameters must either be
<a class="reference internal" href="#django.contrib.gis.geos.LinearRing" title="django.contrib.gis.geos.LinearRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">LinearRing</span></code></a> instances, or a sequence that may be used to construct a
<a class="reference internal" href="#django.contrib.gis.geos.LinearRing" title="django.contrib.gis.geos.LinearRing"><code class="xref py py-class docutils literal notranslate"><span class="pre">LinearRing</span></code></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ext_coords</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">int_coords</span> <span class="o">=</span> <span class="p">((</span><span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.6</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.6</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span><span class="n">ext_coords</span><span class="p">,</span> <span class="n">int_coords</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span><span class="n">LinearRing</span><span class="p">(</span><span class="n">ext_coords</span><span class="p">),</span> <span class="n">LinearRing</span><span class="p">(</span><span class="n">int_coords</span><span class="p">))</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> couldn’t be instantiated.</p>
</div>
<dl class="classmethod">
<dt id="django.contrib.gis.geos.Polygon.from_bbox">
<em class="property">classmethod </em><code class="descname">from_bbox</code>(<em>bbox</em>)<a class="headerlink" href="#django.contrib.gis.geos.Polygon.from_bbox" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a polygon object from the given bounding-box, a 4-tuple
comprising <code class="docutils literal notranslate"><span class="pre">(xmin,</span> <span class="pre">ymin,</span> <span class="pre">xmax,</span> <span class="pre">ymax)</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.Polygon.num_interior_rings">
<code class="descname">num_interior_rings</code><a class="headerlink" href="#django.contrib.gis.geos.Polygon.num_interior_rings" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the number of interior rings in this geometry.</p>
</dd></dl>

</dd></dl>

<div class="admonition-comparing-polygons admonition">
<p class="first admonition-title">Comparing Polygons</p>
<p>Note that it is possible to compare <code class="docutils literal notranslate"><span class="pre">Polygon</span></code> objects directly with <code class="docutils literal notranslate"><span class="pre">&lt;</span></code>
or <code class="docutils literal notranslate"><span class="pre">&gt;</span></code>, but as the comparison is made through Polygon’s
<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a>, it does not mean much (but is consistent and quick).
You can always force the comparison with the <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.area" title="django.contrib.gis.geos.GEOSGeometry.area"><code class="xref py py-attr docutils literal notranslate"><span class="pre">area</span></code></a>
property:</p>
<div class="last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">if</span> <span class="n">poly_1</span><span class="o">.</span><span class="n">area</span> <span class="o">&gt;</span> <span class="n">poly_2</span><span class="o">.</span><span class="n">area</span><span class="p">:</span>
<span class="gp">&gt;&gt;&gt; </span>    <span class="k">pass</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="s-geometry-collections">
<span id="geometry-collections"></span><h2>Geometry Collections<a class="headerlink" href="#geometry-collections" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-multipoint">
<span id="multipoint"></span><h3><code class="docutils literal notranslate"><span class="pre">MultiPoint</span></code><a class="headerlink" href="#multipoint" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.MultiPoint">
<em class="property">class </em><code class="descname">MultiPoint</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.MultiPoint" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">MultiPoint</span></code> objects may be instantiated by passing in <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a>
objects as arguments, or a single sequence of <a class="reference internal" href="#django.contrib.gis.geos.Point" title="django.contrib.gis.geos.Point"><code class="xref py py-class docutils literal notranslate"><span class="pre">Point</span></code></a> objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">mp</span> <span class="o">=</span> <span class="n">MultiPoint</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mp</span> <span class="o">=</span> <span class="n">MultiPoint</span><span class="p">(</span> <span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span> <span class="p">)</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">MultiPoint</span></code> couldn’t be instantiated.</p>
</div>
</dd></dl>

</div>
<div class="section" id="s-multilinestring">
<span id="multilinestring"></span><h3><code class="docutils literal notranslate"><span class="pre">MultiLineString</span></code><a class="headerlink" href="#multilinestring" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.MultiLineString">
<em class="property">class </em><code class="descname">MultiLineString</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.MultiLineString" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">MultiLineString</span></code> objects may be instantiated by passing in
<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> objects as arguments, or a single sequence of
<a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ls1</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ls2</span> <span class="o">=</span> <span class="n">LineString</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mls</span> <span class="o">=</span> <span class="n">MultiLineString</span><span class="p">(</span><span class="n">ls1</span><span class="p">,</span> <span class="n">ls2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mls</span> <span class="o">=</span> <span class="n">MultiLineString</span><span class="p">([</span><span class="n">ls1</span><span class="p">,</span> <span class="n">ls2</span><span class="p">])</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">MultiLineString</span></code> couldn’t be
instantiated.</p>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.MultiLineString.merged">
<code class="descname">merged</code><a class="headerlink" href="#django.contrib.gis.geos.MultiLineString.merged" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.LineString" title="django.contrib.gis.geos.LineString"><code class="xref py py-class docutils literal notranslate"><span class="pre">LineString</span></code></a> representing the line merge of
all the components in this <code class="docutils literal notranslate"><span class="pre">MultiLineString</span></code>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.MultiLineString.closed">
<code class="descname">closed</code><a class="headerlink" href="#django.contrib.gis.geos.MultiLineString.closed" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if and only if all elements are closed. Requires GEOS 3.5.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-multipolygon">
<span id="multipolygon"></span><h3><code class="docutils literal notranslate"><span class="pre">MultiPolygon</span></code><a class="headerlink" href="#multipolygon" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.MultiPolygon">
<em class="property">class </em><code class="descname">MultiPolygon</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.MultiPolygon" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">MultiPolygon</span></code> objects may be instantiated by passing <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a>
objects as arguments, or a single sequence of <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">p1</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p2</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span> <span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mp</span> <span class="o">=</span> <span class="n">MultiPolygon</span><span class="p">(</span><span class="n">p1</span><span class="p">,</span> <span class="n">p2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mp</span> <span class="o">=</span> <span class="n">MultiPolygon</span><span class="p">([</span><span class="n">p1</span><span class="p">,</span> <span class="n">p2</span><span class="p">])</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">MultiPolygon</span></code> couldn’t be
instantiated.</p>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.MultiPolygon.cascaded_union">
<code class="descname">cascaded_union</code><a class="headerlink" href="#django.contrib.gis.geos.MultiPolygon.cascaded_union" title="Permalink to this definition">¶</a></dt>
<dd><div class="deprecated">
<p><span class="versionmodified">Deprecated since version 1.10: </span>Use the <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.unary_union" title="django.contrib.gis.geos.GEOSGeometry.unary_union"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.unary_union</span></code></a> property instead.</p>
</div>
<p>Returns a <a class="reference internal" href="#django.contrib.gis.geos.Polygon" title="django.contrib.gis.geos.Polygon"><code class="xref py py-class docutils literal notranslate"><span class="pre">Polygon</span></code></a> that is the union of all of the component
polygons in this collection.  The algorithm employed is significantly
more efficient (faster) than trying to union the geometries together
individually. <a class="footnote-reference" href="#fncascadedunion" id="id7">[2]</a></p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="s-geometrycollection">
<span id="geometrycollection"></span><h3><code class="docutils literal notranslate"><span class="pre">GeometryCollection</span></code><a class="headerlink" href="#geometrycollection" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.GeometryCollection">
<em class="property">class </em><code class="descname">GeometryCollection</code>(<em>*args</em>, <em>**kwargs</em>)<a class="headerlink" href="#django.contrib.gis.geos.GeometryCollection" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">GeometryCollection</span></code> objects may be instantiated by passing in other
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> as arguments, or a single sequence of
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> objects:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="n">Polygon</span><span class="p">(</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> <span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gc</span> <span class="o">=</span> <span class="n">GeometryCollection</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">MultiPoint</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> <span class="n">poly</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gc</span> <span class="o">=</span> <span class="n">GeometryCollection</span><span class="p">((</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">MultiPoint</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> <span class="n">poly</span><span class="p">))</span>
</pre></div>
</div>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>In previous versions, an empty <code class="docutils literal notranslate"><span class="pre">GeometryCollection</span></code> couldn’t be
instantiated.</p>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="s-prepared-geometries">
<span id="s-id8"></span><span id="prepared-geometries"></span><span id="id8"></span><h2>Prepared Geometries<a class="headerlink" href="#prepared-geometries" title="Permalink to this headline">¶</a></h2>
<p>In order to obtain a prepared geometry, just access the
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry.prepared" title="django.contrib.gis.geos.GEOSGeometry.prepared"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GEOSGeometry.prepared</span></code></a> property.  Once you have a
<code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code> instance its spatial predicate methods, listed below,
may be used with other <code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code> objects.  An operation with a prepared
geometry can be orders of magnitude faster – the more complex the geometry
that is prepared, the larger the speedup in the operation.  For more information,
please consult the <a class="reference external" href="https://trac.osgeo.org/geos/wiki/PreparedGeometry">GEOS wiki page on prepared geometries</a>.</p>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">Polygon</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">poly</span> <span class="o">=</span> <span class="n">Polygon</span><span class="o">.</span><span class="n">from_bbox</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prep_poly</span> <span class="o">=</span> <span class="n">poly</span><span class="o">.</span><span class="n">prepared</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prep_poly</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">Point</span><span class="p">(</span><span class="mf">2.5</span><span class="p">,</span> <span class="mf">2.5</span><span class="p">))</span>
<span class="go">True</span>
</pre></div>
</div>
<div class="section" id="s-preparedgeometry">
<span id="preparedgeometry"></span><h3><code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code><a class="headerlink" href="#preparedgeometry" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.contrib.gis.geos.PreparedGeometry">
<em class="property">class </em><code class="descname">PreparedGeometry</code><a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry" title="Permalink to this definition">¶</a></dt>
<dd><p>All methods on <code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code> take an <code class="docutils literal notranslate"><span class="pre">other</span></code> argument, which
must be a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> instance.</p>
<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.contains">
<code class="descname">contains</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.contains" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.contains_properly">
<code class="descname">contains_properly</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.contains_properly" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.covers">
<code class="descname">covers</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.covers" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.crosses">
<code class="descname">crosses</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.crosses" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.disjoint">
<code class="descname">disjoint</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.disjoint" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.intersects">
<code class="descname">intersects</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.intersects" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.overlaps">
<code class="descname">overlaps</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.overlaps" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.touches">
<code class="descname">touches</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.touches" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="django.contrib.gis.geos.PreparedGeometry.within">
<code class="descname">within</code>(<em>other</em>)<a class="headerlink" href="#django.contrib.gis.geos.PreparedGeometry.within" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</div>
</div>
<div class="section" id="s-geometry-factories">
<span id="geometry-factories"></span><h2>Geometry Factories<a class="headerlink" href="#geometry-factories" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="django.contrib.gis.geos.fromfile">
<code class="descname">fromfile</code>(<em>file_h</em>)<a class="headerlink" href="#django.contrib.gis.geos.fromfile" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>file_h</strong> (a Python <code class="docutils literal notranslate"><span class="pre">file</span></code> object or a string path to the file) – input file that contains spatial data</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> corresponding to the spatial data in the file</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">fromfile</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">fromfile</span><span class="p">(</span><span class="s1">&#39;/home/bob/geom.wkt&#39;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="django.contrib.gis.geos.fromstr">
<code class="descname">fromstr</code>(<em>string</em>, <em>srid=None</em>)<a class="headerlink" href="#django.contrib.gis.geos.fromstr" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>string</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.7)"><em>str</em></a>) – string that contains spatial data</li>
<li><strong>srid</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.7)"><em>int</em></a>) – spatial reference identifier</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> corresponding to the spatial data in the string</p>
</td>
</tr>
</tbody>
</table>
<p><code class="docutils literal notranslate"><span class="pre">fromstr(string,</span> <span class="pre">srid)</span></code> is equivalent to
<a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry(string,</span> <span class="pre">srid)</span></code></a>.</p>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">fromstr</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">fromstr</span><span class="p">(</span><span class="s1">&#39;POINT(-90.5 29.5)&#39;</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-i-o-objects">
<span id="i-o-objects"></span><h2>I/O Objects<a class="headerlink" href="#i-o-objects" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-reader-objects">
<span id="reader-objects"></span><h3>Reader Objects<a class="headerlink" href="#reader-objects" title="Permalink to this headline">¶</a></h3>
<p>The reader I/O classes simply return a <a class="reference internal" href="#django.contrib.gis.geos.GEOSGeometry" title="django.contrib.gis.geos.GEOSGeometry"><code class="xref py py-class docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a> instance from the
WKB and/or WKT input given to their <code class="docutils literal notranslate"><span class="pre">read(geom)</span></code> method.</p>
<dl class="class">
<dt id="django.contrib.gis.geos.WKBReader">
<em class="property">class </em><code class="descname">WKBReader</code><a class="headerlink" href="#django.contrib.gis.geos.WKBReader" title="Permalink to this definition">¶</a></dt>
<dd><p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">WKBReader</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_r</span> <span class="o">=</span> <span class="n">WKBReader</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">&#39;0101000000000000000000F03F000000000000F03F&#39;</span><span class="p">)</span>
<span class="go">&lt;Point object at 0x103a88910&gt;</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="django.contrib.gis.geos.WKTReader">
<em class="property">class </em><code class="descname">WKTReader</code><a class="headerlink" href="#django.contrib.gis.geos.WKTReader" title="Permalink to this definition">¶</a></dt>
<dd><p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">WKTReader</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_r</span> <span class="o">=</span> <span class="n">WKTReader</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s1">&#39;POINT(1 1)&#39;</span><span class="p">)</span>
<span class="go">&lt;Point object at 0x103a88b50&gt;</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="s-writer-objects">
<span id="writer-objects"></span><h3>Writer Objects<a class="headerlink" href="#writer-objects" title="Permalink to this headline">¶</a></h3>
<p>All writer objects have a <code class="docutils literal notranslate"><span class="pre">write(geom)</span></code> method that returns either the
WKB or WKT of the given geometry.  In addition, <a class="reference internal" href="#django.contrib.gis.geos.WKBWriter" title="django.contrib.gis.geos.WKBWriter"><code class="xref py py-class docutils literal notranslate"><span class="pre">WKBWriter</span></code></a> objects
also have properties that may be used to change the byte order, and or
include the SRID value (in other words, EWKB).</p>
<dl class="class">
<dt id="django.contrib.gis.geos.WKBWriter">
<em class="property">class </em><code class="descname">WKBWriter</code>(<em>dim=2</em>)<a class="headerlink" href="#django.contrib.gis.geos.WKBWriter" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">WKBWriter</span></code> provides the most control over its output.  By default it
returns OGC-compliant WKB when its <code class="docutils literal notranslate"><span class="pre">write</span></code> method is called.  However,
it has properties that allow for the creation of EWKB, a superset of the
WKB standard that includes additional information. See the
<a class="reference internal" href="#django.contrib.gis.geos.WKBWriter.outdim" title="django.contrib.gis.geos.WKBWriter.outdim"><code class="xref py py-attr docutils literal notranslate"><span class="pre">WKBWriter.outdim</span></code></a> documentation for more details about the <code class="docutils literal notranslate"><span class="pre">dim</span></code>
argument.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>The ability to pass the <code class="docutils literal notranslate"><span class="pre">dim</span></code> argument to the constructor was added.</p>
</div>
<dl class="method">
<dt id="django.contrib.gis.geos.WKBWriter.write">
<code class="descname">write</code>(<em>geom</em>)<a class="headerlink" href="#django.contrib.gis.geos.WKBWriter.write" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Returns the WKB of the given geometry as a Python <code class="docutils literal notranslate"><span class="pre">buffer</span></code> object.
Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKBWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span> <span class="o">=</span> <span class="n">WKBWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&lt;read-only buffer for 0x103a898f0, size -1, offset 0 at 0x103a89930&gt;</span>
</pre></div>
</div>
<dl class="method">
<dt id="django.contrib.gis.geos.WKBWriter.write_hex">
<code class="descname">write_hex</code>(<em>geom</em>)<a class="headerlink" href="#django.contrib.gis.geos.WKBWriter.write_hex" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Returns WKB of the geometry in hexadecimal.  Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKBWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span> <span class="o">=</span> <span class="n">WKBWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;0101000000000000000000F03F000000000000F03F&#39;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.WKBWriter.byteorder">
<code class="descname">byteorder</code><a class="headerlink" href="#django.contrib.gis.geos.WKBWriter.byteorder" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>This property may be set to change the byte-order of the geometry
representation.</p>
<table class="docutils">
<colgroup>
<col width="23%" />
<col width="77%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Byteorder Value</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>0</td>
<td>Big Endian (e.g., compatible with RISC systems)</td>
</tr>
<tr class="row-odd"><td>1</td>
<td>Little Endian (e.g., compatible with x86 systems)</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKBWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span> <span class="o">=</span> <span class="n">WKBWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;0101000000000000000000F03F000000000000F03F&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">byteorder</span> <span class="o">=</span> <span class="mi">0</span>
<span class="go">&#39;00000000013FF00000000000003FF0000000000000&#39;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.WKBWriter.outdim">
<code class="descname">outdim</code><a class="headerlink" href="#django.contrib.gis.geos.WKBWriter.outdim" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>This property may be set to change the output dimension of the geometry
representation.  In other words, if you have a 3D geometry then set to 3
so that the Z value is included in the WKB.</p>
<table class="docutils">
<colgroup>
<col width="31%" />
<col width="69%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Outdim Value</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>2</td>
<td>The default, output 2D WKB.</td>
</tr>
<tr class="row-odd"><td>3</td>
<td>Output 3D WKB.</td>
</tr>
</tbody>
</table>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKBWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span> <span class="o">=</span> <span class="n">WKBWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">outdim</span>
<span class="go">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span> <span class="c1"># By default, no Z value included:</span>
<span class="go">&#39;0101000000000000000000F03F000000000000F03F&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">outdim</span> <span class="o">=</span> <span class="mi">3</span> <span class="c1"># Tell writer to include Z values</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;0101000080000000000000F03F000000000000F03F000000000000F03F&#39;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.WKBWriter.srid">
<code class="descname">srid</code><a class="headerlink" href="#django.contrib.gis.geos.WKBWriter.srid" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Set this property with a boolean to indicate whether the SRID of the
geometry should be included with the WKB representation.  Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKBWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span> <span class="o">=</span> <span class="n">WKBWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span> <span class="c1"># By default, no SRID included:</span>
<span class="go">&#39;0101000000000000000000F03F000000000000F03F&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">srid</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># Tell writer to include SRID</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkb_w</span><span class="o">.</span><span class="n">write_hex</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;0101000020E6100000000000000000F03F000000000000F03F&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="django.contrib.gis.geos.WKTWriter">
<em class="property">class </em><code class="descname">WKTWriter</code>(<em>dim=2</em>, <em>trim=False</em>, <em>precision=None</em>)<a class="headerlink" href="#django.contrib.gis.geos.WKTWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>This class allows outputting the WKT representation of a geometry. See the
<a class="reference internal" href="#django.contrib.gis.geos.WKBWriter.outdim" title="django.contrib.gis.geos.WKBWriter.outdim"><code class="xref py py-attr docutils literal notranslate"><span class="pre">WKBWriter.outdim</span></code></a>, <a class="reference internal" href="#django.contrib.gis.geos.WKTWriter.trim" title="django.contrib.gis.geos.WKTWriter.trim"><code class="xref py py-attr docutils literal notranslate"><span class="pre">trim</span></code></a>, and <a class="reference internal" href="#django.contrib.gis.geos.WKTWriter.precision" title="django.contrib.gis.geos.WKTWriter.precision"><code class="xref py py-attr docutils literal notranslate"><span class="pre">precision</span></code></a> attributes for
details about the constructor arguments.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.10:</span> <p>The ability to pass the <code class="docutils literal notranslate"><span class="pre">dim</span></code>, <code class="docutils literal notranslate"><span class="pre">trim</span></code>, and <code class="docutils literal notranslate"><span class="pre">precision</span></code> arguments
to the constructor was added.</p>
</div>
<dl class="method">
<dt id="django.contrib.gis.geos.WKTWriter.write">
<code class="descname">write</code>(<em>geom</em>)<a class="headerlink" href="#django.contrib.gis.geos.WKTWriter.write" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Returns the WKT of the given geometry. Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKTWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span> <span class="o">=</span> <span class="n">WKTWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1.0000000000000000 1.0000000000000000)&#39;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.WKTWriter.outdim">
<code class="descname">outdim</code><a class="headerlink" href="#django.contrib.gis.geos.WKTWriter.outdim" title="Permalink to this definition">¶</a></dt>
<dd><p>See <a class="reference internal" href="#django.contrib.gis.geos.WKBWriter.outdim" title="django.contrib.gis.geos.WKBWriter.outdim"><code class="xref py py-attr docutils literal notranslate"><span class="pre">WKBWriter.outdim</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.contrib.gis.geos.WKTWriter.trim">
<code class="descname">trim</code><a class="headerlink" href="#django.contrib.gis.geos.WKTWriter.trim" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>This property is used to enable or disable trimming of
unnecessary decimals.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKTWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span> <span class="o">=</span> <span class="n">WKTWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">trim</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1.0000000000000000 1.0000000000000000)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">trim</span> <span class="o">=</span> <span class="kc">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1 1)&#39;</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="django.contrib.gis.geos.WKTWriter.precision">
<code class="descname">precision</code><a class="headerlink" href="#django.contrib.gis.geos.WKTWriter.precision" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.10.</span> </div>
<p>This property controls the rounding precision of coordinates;
if set to <code class="docutils literal notranslate"><span class="pre">None</span></code> rounding is disabled.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.geos</span> <span class="k">import</span> <span class="n">Point</span><span class="p">,</span> <span class="n">WKTWriter</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pnt</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="mf">1.44</span><span class="p">,</span> <span class="mf">1.66</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span> <span class="o">=</span> <span class="n">WKTWriter</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">wkt_w</span><span class="o">.</span><span class="n">precision</span><span class="p">)</span>
<span class="go">None</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1.4399999999999999 1.6599999999999999)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">precision</span> <span class="o">=</span> <span class="mi">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1 2)&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">precision</span> <span class="o">=</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">wkt_w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">pnt</span><span class="p">)</span>
<span class="go">&#39;POINT (1.4 1.7)&#39;</span>
</pre></div>
</div>
</dd></dl>

<p class="rubric">Footnotes</p>
<table class="docutils footnote" frame="void" id="fnogc" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id5">[1]</a></td><td><em>See</em> <a class="reference external" href="https://postgis.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT">PostGIS EWKB, EWKT and Canonical Forms</a>, PostGIS documentation at Ch. 4.1.2.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="fncascadedunion" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id7">[2]</a></td><td>For more information, read Paul Ramsey’s blog post about <a class="reference external" href="http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html">(Much) Faster Unions in PostGIS 1.4</a> and Martin Davis’ blog post on <a class="reference external" href="http://lin-ear-th-inking.blogspot.com/2007/11/fast-polygon-merging-in-jts-using.html">Fast polygon merging in JTS using Cascaded Union</a>.</td></tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="s-settings">
<span id="settings"></span><h2>Settings<a class="headerlink" href="#settings" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-geos-library-path">
<span id="s-std:setting-GEOS_LIBRARY_PATH"></span><span id="geos-library-path"></span><span id="std:setting-GEOS_LIBRARY_PATH"></span><h3><code class="docutils literal notranslate"><span class="pre">GEOS_LIBRARY_PATH</span></code><a class="headerlink" href="#geos-library-path" title="Permalink to this headline">¶</a></h3>
<p>A string specifying the location of the GEOS C library.  Typically,
this setting is only used if the GEOS C library is in a non-standard
location (e.g., <code class="docutils literal notranslate"><span class="pre">/home/bob/lib/libgeos_c.so</span></code>).</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The setting must be the <em>full</em> path to the <strong>C</strong> shared library; in
other words you want to use <code class="docutils literal notranslate"><span class="pre">libgeos_c.so</span></code>, not <code class="docutils literal notranslate"><span class="pre">libgeos.so</span></code>.</p>
</div>
</div>
</div>
<div class="section" id="s-exceptions">
<span id="exceptions"></span><h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h2>
<dl class="exception">
<dt id="django.contrib.gis.geos.GEOSException">
<em class="property">exception </em><code class="descname">GEOSException</code><a class="headerlink" href="#django.contrib.gis.geos.GEOSException" title="Permalink to this definition">¶</a></dt>
<dd><p>The base GEOS exception, indicates a GEOS-related error.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">GEOS API</a><ul>
<li><a class="reference internal" href="#background">Background</a><ul>
<li><a class="reference internal" href="#what-is-geos">What is GEOS?</a></li>
<li><a class="reference internal" href="#features">Features</a></li>
</ul>
</li>
<li><a class="reference internal" href="#tutorial">Tutorial</a><ul>
<li><a class="reference internal" href="#creating-a-geometry">Creating a Geometry</a></li>
<li><a class="reference internal" href="#geometries-are-pythonic">Geometries are Pythonic</a></li>
</ul>
</li>
<li><a class="reference internal" href="#geometry-objects">Geometry Objects</a><ul>
<li><a class="reference internal" href="#geosgeometry"><code class="docutils literal notranslate"><span class="pre">GEOSGeometry</span></code></a><ul>
<li><a class="reference internal" href="#properties">Properties</a></li>
<li><a class="reference internal" href="#output-properties">Output Properties</a></li>
<li><a class="reference internal" href="#spatial-predicate-methods">Spatial Predicate Methods</a></li>
<li><a class="reference internal" href="#topological-methods">Topological Methods</a></li>
<li><a class="reference internal" href="#topological-properties">Topological Properties</a></li>
<li><a class="reference internal" href="#other-properties-methods">Other Properties &amp; Methods</a></li>
</ul>
</li>
<li><a class="reference internal" href="#point"><code class="docutils literal notranslate"><span class="pre">Point</span></code></a></li>
<li><a class="reference internal" href="#linestring"><code class="docutils literal notranslate"><span class="pre">LineString</span></code></a></li>
<li><a class="reference internal" href="#linearring"><code class="docutils literal notranslate"><span class="pre">LinearRing</span></code></a></li>
<li><a class="reference internal" href="#polygon"><code class="docutils literal notranslate"><span class="pre">Polygon</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#geometry-collections">Geometry Collections</a><ul>
<li><a class="reference internal" href="#multipoint"><code class="docutils literal notranslate"><span class="pre">MultiPoint</span></code></a></li>
<li><a class="reference internal" href="#multilinestring"><code class="docutils literal notranslate"><span class="pre">MultiLineString</span></code></a></li>
<li><a class="reference internal" href="#multipolygon"><code class="docutils literal notranslate"><span class="pre">MultiPolygon</span></code></a></li>
<li><a class="reference internal" href="#geometrycollection"><code class="docutils literal notranslate"><span class="pre">GeometryCollection</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#prepared-geometries">Prepared Geometries</a><ul>
<li><a class="reference internal" href="#preparedgeometry"><code class="docutils literal notranslate"><span class="pre">PreparedGeometry</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#geometry-factories">Geometry Factories</a></li>
<li><a class="reference internal" href="#i-o-objects">I/O Objects</a><ul>
<li><a class="reference internal" href="#reader-objects">Reader Objects</a></li>
<li><a class="reference internal" href="#writer-objects">Writer Objects</a></li>
</ul>
</li>
<li><a class="reference internal" href="#settings">Settings</a><ul>
<li><a class="reference internal" href="#geos-library-path"><code class="docutils literal notranslate"><span class="pre">GEOS_LIBRARY_PATH</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#exceptions">Exceptions</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="measure.html"
                        title="previous chapter">Measurement Objects</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="gdal.html"
                        title="next chapter">GDAL API</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/ref/contrib/gis/geos.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Jun 03, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="measure.html" title="Measurement Objects">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="gdal.html" title="GDAL API">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>